<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!-- 写了个公共类，把要导入的公共的文件写到一块，${ctx} -->		    
<%@include file="/WEB-INF/jsp/common/taglibs.jsp"%>      
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="${ctx}/lib/bootstrap-3.3.7-dist/css/bootstrap.css" />
<script type="text/javascript" src="${ctx}/lib/jquery/jquery-1.11.1.js" ></script>
<script type="text/javascript" src="${ctx}/lib/bootstrap-3.3.7-dist/js/npm.js" ></script>
<script type="text/javascript" src="${ctx}/lib/layer-v3.1.1/layer/layer.js" ></script>
<script type="text/javascript" src="${ctx}/lib/bootstrap-3.3.7-dist/js/mylayer.js" ></script>
</head>
<body>
	<form id="updata_form" action="${ctx}/banji/update.action" method="post">
		<!-- 根据选中的id，拿到默认的值  hidden隐藏的-->
		<input type="hidden" name="id" value="${banji.id}"><br/>
		班级名称：<input type="text" name="name" value="${banji.name}"><br/>
		班级人数：<input type="text" name="people" value="${banji.people}"><br/>
		任课教师：<input type="text" name="teatch" value="${banji.teatch}"><br/>
		课程名称：<input type="text" readonly="readonly" name="courseName"  value="${banji.courseName}"/>
		<br/>
		 更改课程：
		<select name="courseId">
			<!-- <option>--请选择--</option> -->
			<c:forEach items="${list}" var="course">
				<option value="${course.id}">${course.name}</option>
			</c:forEach>
		</select> 
		<br/>
		<input type="button" onclick="updata()" value="修改">
		<input type="reset" value="重置">
		
		<script type="text/javascript">
			function updata(){
				$.ajax({
					url : "${ctx}/banji/update.action",
					type : "post",
					dataType : "json",
					data : $("#updata_form").serialize(),
					success : function(data){
						if(data){
							mylayer.success("添加成功");
							var index = parent.layer.getFrameIndex(window.name);
							setTimeout(function(){
								parent.layer.close(index);
								window.parent.location.reload();
							},1000)
						} else {
							mylayer.errorMsg("添加失败");
						}
					}
				});
			}
		</script>
	</form>
	
</body>
</html>